package cn.sdormitory.controller;

import cn.sdormitory.common.api.CommonResult;
import cn.sdormitory.exam.entity.Exam;
import cn.sdormitory.exam.service.ClassroomTestService;
import cn.sdormitory.exam.vo.*;
import cn.sdormitory.service.AppExamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : yy
 * @date: 2024/12/30 16:58
 * @description:
 */
@RestController
@RequestMapping("/app/exam")
@Api("APP端考试管理")
public class AppExamController {
    @Resource
    private AppExamService appExamService;

    @Resource
    private ClassroomTestService classroomTestService;

    @ApiOperation(value = "获取学生考试信息")
    @GetMapping("/getExam/{studentId}")
    public CommonResult<List<Exam>> getExam(@PathVariable("studentId") Integer studentId) {
        List<Exam> list = appExamService.getExam(studentId);
        return CommonResult.success(list);
    }
    @ApiOperation(value = "获取学生考试信息详情")
    @GetMapping("/getExamDetail/{examId}/{studentId}")
    public CommonResult<List<AppStudentExamDetailVo>> getExamDetail(@PathVariable("examId") Integer examId,
                                                              @PathVariable("studentId") Integer studentId) {
        List<AppStudentExamDetailVo> list = appExamService.getExamDetail(examId, studentId);
        return CommonResult.success(list);
    }
    @ApiOperation(value = "根据用户id查询该用户下班级考试信息")
    @GetMapping("/getClassExam/{userId}")
    public CommonResult<List<Exam>> getClassExam(@PathVariable("userId") Long userId) {
        List<Exam> list = appExamService.getClassExam(userId);
        return CommonResult.success(list);
    }
    @ApiOperation(value = "根据考试id查询班级考试统计信息")
    @GetMapping("/getClassExamCount/{examId}")
    public CommonResult<List<AppClassExamCountVo>> getClassExamCount(@PathVariable("examId") Integer examId) {
        return CommonResult.success(appExamService.getClassExamCount(examId));
    }










    @ApiOperation(value = "获取学生课堂测试成绩")
    @GetMapping("/getClassRoomTestRecord/{id}")
    public CommonResult<List<AppClassroomTestRecordVo>>  getClassRoomTestRecord(@PathVariable("id") Integer studentId) {
        List<AppClassroomTestRecordVo> testRecordVos = appExamService.getClassRoomTestRecord(studentId);
        return CommonResult.success(testRecordVos);
    }
    @ApiOperation(value = "根据用户id查询课堂测试统计信息-仅限班主任和部门经理使用")
    @GetMapping("/getTestCount/{id}")
    public CommonResult<List<ClassroomTestVo>> getTestCount(@PathVariable("id") Long userId) {
        return CommonResult.success(appExamService.getTestCount(userId));
    }
    @ApiOperation(value = "获取该课堂测试下班级学生的成绩记录")
    @GetMapping("/getClassroomTestRecord")
    public CommonResult<List<ClassroomTestRecordVo>> getClassroomTestRecord(@RequestParam("classId") Integer classId,
                                                                            @RequestParam("testId") Integer testId) {
        List<ClassroomTestRecordVo> list = classroomTestService.getClassroomTestRecord(classId,testId);
        return CommonResult.success(list);
    }

}
